package com.tencent.config;

import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ThreadPoolUtils {
    /**
     * int corePoolSize, 核心线程数  5
     * int maximumPoolSize, 最大线程数   10
     * long keepAliveTime, 超出核心线程数的线程存活时间  2
     * TimeUnit unit, 存活时间对应的时间单位   s
     * BlockingQueue<Runnable> workQueue, 等待队列  100
     * ThreadFactory threadFactory, 线程工厂  default
     * RejectedExecutionHandler handler  拒绝策略  abort
     *
     * */
    public  static ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
            5
            ,5,
            0,
            TimeUnit.SECONDS,
            new LinkedBlockingDeque<>(),
            Executors.defaultThreadFactory(),
            new ThreadPoolExecutor.AbortPolicy()
    );
    public static  ThreadPoolExecutor getThreadPoolExecutor(){
        return threadPoolExecutor;
    }
}
